<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>广告联调平台</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="../layui/css/layui.css" rel="stylesheet">
</head>
<body>
  <div class="layui-layout layui-layout-admin">
    <div class="layui-header">
      <div class="layui-logo layui-hide-xs layui-bg-black">广告联调平台</div>
      <!-- 头部区域（可配合layui 已有的水平导航） -->
      <ul class="layui-nav layui-layout-right">
        <li class="layui-nav-item layui-hide layui-show-sm-inline-block">
          <a>
            <img src="../img/yonghu.png" class="layui-nav-img">
            <span id="uName"></span>
          </a>
          <dl class="layui-nav-child">
            <dd><a lay-on="confirm">退出登录</a></dd>
          </dl>
        </li>
      </ul>
    </div>
    <div class="layui-side layui-bg-black">
      <div class="layui-side-scroll">
        <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
        <ul class="layui-nav layui-nav-tree" lay-filter="test">
          <li class="layui-nav-item layui-nav-itemed"><a href="../admin.html">首页</a></li>
          <li class="layui-nav-item">
            <a class="" href="javascript:;">oppo</a>
            <dl class="layui-nav-child">
              <dd><a href="oppoIndex.html">数据汇总</a></dd>
              <dd><a href="../admin.html">数据明细</a></dd>
              <dd><a href="../admin.html">链接管理</a></dd>
              <dd><a href="create.html">链接创建</a></dd>
            </dl>
          </li>
          <li class="layui-nav-item">
            <a class="" href="javascript:;">优酷</a>
            <dl class="layui-nav-child">
                <dd><a href="../youku/selecteff.html">有效触点监测地址</a></dd>  
                <dd><a href="../youku/effpoint.html">有效触点链接</a></dd>
                <dd><a href="../youku/selectadinfo.html">联调触点列表</a></dd>  
                <dd><a href="../youku/xianyuinfo.html">闲鱼触点列表</a></dd>  
            </dl>
          </li>
          <li class="layui-nav-item">
            <a class="" href="javascript:;">淘宝</a>
            <dl class="layui-nav-child">
                <dd><a href="../taobao/deeplinkTb.html">deeplink转换工具</a></dd>
            </dl>
          </li>
          <li class="layui-nav-item"><a href="../admin.html">完善信息</a></li>
        </ul>
      </div>
    </div>
    <div class="layui-body">
      <!-- 内容主体区域 -->
      <div style="padding: 15px;">
        <form class="layui-form" action="">
          <div class="layui-card layui-panel">
            <div class="layui-card-header">
              链接创建
            </div>
            <div class="layui-card-body">
              <div class="layui-form-item">
                <label class="layui-form-label">*链接标题</label>
                <div class="layui-input-block">
                  <input type="text" name="title" id="title" lay-verify="required" placeholder="链接标题" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">*OPPO账号ID</label>
                <div class="layui-input-block">
                  <input type="text" name="ownerId" id="ownerId" lay-verify="required" placeholder="OPPO账号ID" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">*OPPO的APIID</label>
                <div class="layui-input-block">
                  <input type="text" name="oppoApiID" id="oppoApiID" lay-verify="required" placeholder="OPPO的APIID" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">*oppoApiKey</label>
                <div class="layui-input-block">
                  <input type="text" name="oppoApiKey" id="oppoApiKey" lay-verify="required" placeholder="oppoApiKey" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">*回传比例</label>
                <div class="layui-input-block">
                  <input type="number" lay-affix="number" lay-precision="0" name="paidAmount" id="paidAmount" lay-verify="required" placeholder="回传比例" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">确定提交</button>
                </div>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
    <div class="layui-footer" style="text-align: center;">
      <!-- 底部固定区域 -->
      冀ICP备2025105329号
    </div>
  </div>

  <script src="../layui/layui.js"></script>
  <script>
    //JS
    layui.use(['form','element', 'layer', 'util'], function(){
      var form = layui.form;
      var element = layui.element;
      var layer = layui.layer;
      var util = layui.util;
      var $ = layui.$;
      var query = layui.jquery;
      var userInfo = {};

      window.onload = function() {
        query.ajax({
          type:"POST",
          url:"/user/queryUser",
          success:function(result){
            if (result.success === true) {
              userInfo = result.user;
              $('#uName').text(userInfo.mobileNo);
            } else {
              layer.alert('获取用户信息失败，请重新登录！', {
                title: '发生错误'
              });
              setTimeout(function(){
                window.location.href = "/";
              }, 1500)
            }
          },
          error:function(){
            layer.alert('访问链接不存在！', {
              title: '发生错误'
            });
          }
        });

      };


      util.on('lay-on',{
        confirm: function() {
          layer.confirm('是否退出登录？', {
            btn: ['确定']
          }, function(){
            query.ajax({
              type:"GET",
              url:"/user/logout",
              success:function(result){
                if (result.success === true) {
                  layer.msg(result.msg, { icon:1 });
                  setTimeout(function(){
                    window.location.href = "/";
                  }, 1500)
                } else {
                  layer.msg(result.msg, { icon:2 });
                }
              },
              error:function(){
                layer.alert('访问链接不存在！', {
                  title: '发生错误'
                });
              }
            })
          })
        }
      });

      // 提交事件
      form.on('submit(demo1)', function(data){
        var field = data.field; // 获取表单字段值
        field.mobileNo = userInfo.mobileNo;

        // 显示填写结果，仅作演示用
        // layer.alert(JSON.stringify(field), {
        //   title: '当前填写的字段值'
        // });
        query.ajax({
          type:"POST",
          contentType:"application/json;charset=UTF-8",
          data:JSON.stringify(field),
          dataType:"json",
          url:"/oppo/insertUrl",
          success:function(result){
            if (result.success === true) {
              layer.msg(result.msg, { icon:1 });
              setTimeout(function(){
                location.reload();
              }, 1500)
            } else {
              layer.msg(result.msg, { icon:2 });
            }
          },
          error:function(){
            layer.alert('访问链接不存在！', {
              title: '发生错误'
            });
          }
        })
        return false; // 阻止默认 form 跳转
      });

    });
  </script>

</body>
</html>